import request from '@/utils/request'

// api地址
const api = {
  list: '/app/delivery/list',
  defaultId: '/app/delivery/loadDefault',
  detail: '/app/delivery/load',
  add: '/app/delivery/add',
  edit: '/app/delivery/update',
  setDefault: '/app/delivery/setDefault',
  remove: '/app/delivery/delete'
}

// 收货地址列表
export const list = (param) => {
  return request.get(api.list, param)
}

// 默认收货地址ID
export const defaultId = (param) => {
  return request.get(api.defaultId, param)
}

// 收货地址详情
export const detail = (addressId) => {
  return request.get(api.detail, { id:addressId })
}

// 新增收货地址
export const add = (data) => {
  return request.post(api.add, data)
}

// 编辑收货地址
export const edit = (addressId, data) => {
  data.id = addressId;
  return request.post(api.edit, data)
}

// 设置默认收货地址
export const setDefault = (addressId) => {
  return request.get(api.setDefault, { id:addressId })
}

// 删除收货地址
export const remove = (addressId) => {
  return request.get(api.remove, { id:addressId })
}
